import {
  q as o,
  p as T,
  ap as A,
  X as v,
  f as O,
  H as F,
  av as b,
  aw as H,
  k as j,
  m as q,
  l as E,
  az as G,
  as as r,
  aG as P,
  at as m
} from "./index-b50e6ef9.js";
import { f as x } from "./finance-81050a55.js";
function $(w) {
  const d = o([]),
    s = o(!0);
  o({}), T();
  const y = o(1),
    p = o(10),
    t = o([]),
    c = o({}),
    C = A("reload"),
    h = v({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    S = v({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    B = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 90 },
      { label: "积分", prop: "money", minWidth: 80 },
      { label: "类型", prop: "type_name", minWidth: 90 },
      {
        label: "备注",
        prop: "content",
        minWidth: 90,
        formatter: ({ content: e }) =>
          e ||
          j(
            E("el-tag"),
            { class: "mx-1", type: "info", effect: "light" },
            { default: () => [q("暂无")] }
          )
      },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    _ = O(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function W(e) {
    G(e);
  }
  async function D(e) {
    const a = { role_id: e.role_id },
      l = JSON.stringify(a),
      g = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(l)) },
      i = await P(g);
    i.code == 200
      ? (m("删除成功", { type: "success" }), C())
      : m(i.msg, { type: "error" });
  }
  function I() {}
  function z(e) {
    (p.value = e), f(void 0, e);
  }
  function J(e) {
    (y.value = e), f(e, void 0);
  }
  function k(e) {}
  function L(e) {
    (S.text = `正在加载第${e}页...`),
      (s.value = !0),
      b(600).then(() => {
        s.value = !1;
      });
  }
  async function N(e, a = []) {
    (t.value = []),
      a == null ||
        a.map(V => {
          const M = V,
            R = new Date(M);
          t.value.push(
            R.toLocaleDateString("zh-CN", {
              year: "numeric",
              month: "2-digit",
              day: "2-digit"
            })
          );
        }),
      e.type != "3" && (e.action = ""),
      (s.value = !0),
      (c.value = e);
    const l = {
        page: 1,
        pagesize: p.value,
        content: "money",
        user_phone: e.user_phone,
        type: e.type,
        action: e.action,
        start: t.value[0],
        end: t.value[1]
      },
      u = JSON.stringify(l),
      i = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(u)) },
      { data: n } = await x(i);
    (d.value = n.money.data),
      (h.total = n.money.total),
      setTimeout(() => {
        s.value = !1;
      }, 500);
  }
  async function f(e = y.value, a = p.value) {
    const l = {
        page: e,
        pagesize: a,
        content: "money",
        user_phone: c.value.user_phone,
        type: c.value.type,
        action: c.value.action,
        start: t.value[0],
        end: t.value[1]
      },
      u = JSON.stringify(l),
      i = { value: r.enc.Base64.stringify(r.enc.Utf8.parse(u)) },
      n = await x(i);
    n.code === 200
      ? ((d.value = n.data.money.data),
        (h.total = n.data.money.total),
        setTimeout(() => {
          s.value = !1;
        }, 500))
      : m(n.msg, { type: "error" });
  }
  const U = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    F(() => {
      b().then(() => {
        const { setWatermark: e } = H(w.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        f();
    }),
    {
      loading: s,
      columns: B,
      dataList: d,
      pagination: h,
      buttonClass: _,
      formattedDate: t,
      onSearch: N,
      resetForm: U,
      handleaddUser: I,
      handleUpdate: W,
      handleDelete: D,
      handleSizeChange: z,
      handleCurrentChange: J,
      handleSelectionChange: k,
      onCurrentChange: L
    }
  );
}
export { $ as useRole };
